cmake_minimum_required(VERSION 3.10)
project(Teflon)

SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_BUILD_TYPE Release)

OPTION(USE_OPENGL "use opengl as rendering api" ON)
OPTION(USE_VULKAN "use vulkan as rendering api" OFF)
IF(USE_OPENGL AND USE_VULKAN)
    message(FATAL_ERROR "opengl and vulkan cannot be used simultaneously, please choose one")
ENDIF()

IF (USE_OPENGL)
    ADD_DEFINITIONS(-DOPENGL_API)
ENDIF()

IF (USE_VULKAN)
    ADD_DEFINITIONS(-DVULKAN_API)
ENDIF()

# set include and lib dirs
IF (WIN32)
    # setup for windows
    SET(GLFW3_INCLUDE_DIR "D:/Libs/glfw/include/")
    SET(GLFW3_LIBRARY "D:/Libs/glfw/lib/glfw3.lib")
    SET(GLEW_INCLUDE_DIR "D:/Libs/glew/include/")
    SET(GLEW_LIBRARY "D:/Libs/glew/lib/glew32.lib")  
    SET(GLM_INCLUDE_DIR "D:/Libs/glm/include/")
    SET(TINYOBJLOADER_INCLUDE_DIR "D:/Libs/tinyobjloader/include/")
    SET(ASSIMP_INCLUDE_DIR "D:/Libs/assimp/include")
    SET(ASSIMP_LIBRARY "D:/Libs/assimp/lib/Debug/assimp-vc142-mtd.lib")
    if(MSVC)
        add_definitions(-D_CRT_SECURE_NO_WARNINGS)
    endif()

ELSE (WIN32)
    # setup for mac/linux
    SET(GLFW3_INCLUDE_DIR "/usr/local/include")
    SET(GLFW3_LIBRARY "/usr/local/lib/libglfw.dylib")
    SET(GLEW_INCLUDE_DIR "/usr/local/include")
    SET(GLEW_LIBRARY "/usr/local/lib/libGLEW.dylib")
    SET(GLM_INCLUDE_DIR "/usr/local/include")
    SET(TINYOBJLOADER_INCLUDE_DIR "/usr/local/include")

ENDIF (WIN32)

# set additional include dirs
SET(TEFLON_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/src/")
SET(VENDOR_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/vendor/")

FIND_PACKAGE(OpenGL REQUIRED)

FILE(GLOB_RECURSE SOURCE_FILES "${PROJECT_SOURCE_DIR}/src/*.cpp")
FILE(GLOB_RECURSE SOURCE_C_FILES "${PROJECT_SOURCE_DIR}/src/*.c")
FILE(GLOB_RECURSE HEADER_FILES "${PROJECT_SOURCE_DIR}/src/*.h")

ADD_LIBRARY(
    teflon STATIC
    ${SOURCE_FILES}
    ${SOURCE_C_FILES}
    ${HEADER_FILES}
)

TARGET_INCLUDE_DIRECTORIES(
    teflon PRIVATE
    ${GLFW3_INCLUDE_DIR}
    ${GLEW_INCLUDE_DIR}
    ${GLM_INCLUDE_DIR}
    ${TEFLON_INCLUDE_DIR}
    ${VENDOR_INCLUDE_DIR}
    # ${SOIL2_INCLUDE_DIR}
    ${TINYOBJLOADER_INCLUDE_DIR}
    ${ASSIMP_INCLUDE_DIR}
)

TARGET_LINK_LIBRARIES(
    teflon
    ${GLFW3_LIBRARY}
    ${GLEW_LIBRARY}
    ${OPENGL_LIBRARIES}
    ${SOIL2_LIBRARY}
    ${ASSIMP_LIBRARY}
)

ADD_SUBDIRECTORY(examples/sample2d)
ADD_SUBDIRECTORY(examples/sample3d)
